/**
* @program: src
*
* @description:
*
* @author: Mr.chen
*
* @create: 2022-04-11 10:17
**/
package main

import (
	"do_demo/srv/app/logic/rpc/internal/config"
	"do_demo/srv/app/logic/rpc/internal/server"
	"do_demo/srv/app/logic/rpc/internal/svc"
	"flag"
	"os"
	"os/signal"
	"syscall"
)
func main() {
	flag.Parse()
	if err := config.Init(); err != nil {
		panic(err)
	}
	// 启动http服务
	ctx := svc.NewServiceContext(config.Conf)
	l := server.NewILogicServer(ctx)
	srv := server.NewServer(ctx,l)
	// signal
	c := make(chan os.Signal, 1)
	signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
	for {
		s := <-c
		switch s {
		case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
			srv.GracefulStop()
			return
		case syscall.SIGHUP:
		default:
			return
		}
	}
}

